import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'HomeView',
    component: HomeView,
    redirect: '/home', // 路由重定向
    children: [
      {
        path: '/home',
        name: 'Home',
        meta: {
          requireAuth: false
        },
        component: () => import('@/views/home/index.vue')
      },
      {
        path: '/items',
        name: 'Items',
        meta: {
          requireAuth: false
        },
        component: () => import('@/views/items/index.vue')
      },
      {
        path: '/shopping',
        name: 'Shopping',
        meta: {
          requireAuth: true
        },
        component: () => import('@/views/shopping/index.vue')
      },
      {
        path: '/me',
        name: 'Me',
        meta: {
          requireAuth: true
        },
        component: () => import('@/views/me/index.vue')
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/register/index.vue')
  },
  {
    path: '/me/information',
    name: 'Information',
    component: () => import('@/views/information/index.vue')
  },
  {
    path: '/items/category',
    name: 'Category',
    component: () => import('@/views/items/category.vue')
  },
  {
    path: '/login/forget',
    name: 'Forget',
    component: () => import('@/views/forget/index.vue')
  },
  {
    path: '/registerSubmit/:phone',
    name: 'RegisterSubmit',
    component: () => import('@/views/registerSubmit/index.vue')
  },
  {
    path: '/login/forget/reset',
    name: 'reset',
    component: () => import('@/views/reset/index.vue')
  },
  {
    path: '/me/information/setNickname',
    name: 'SetNickname',
    component: () => import('@/views/setNickname/index.vue')
  },
  {
    path: '/me/information/setPassword',
    name: 'SetPassword',
    component: () => import('@/views/setPassword/index.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
